package com.ssish.saas.eccs.service;

import com.ssish.saas.eccs.mapper.PayorMapper;
import com.ssish.saas.eccs.model.Payor;
import com.ssish.saas.eccs.model.PayorExample;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PayorService {

    @Autowired
    private PayorMapper payorMapper;

    public Payor SelectPayorInfoByCondition(Payor payor){
        PayorExample payorExample = new PayorExample();
        PayorExample.Criteria criteria = payorExample.createCriteria();
        if(StringUtils.isNotBlank(payor.getPayorCode())){
            criteria.andPayorCodeEqualTo(payor.getPayorCode());
        }
        List<Payor>  payorList = payorMapper.selectByExample(payorExample);
        if(payorList != null && payorList.size()>0){
            return payorList.get(0);
        }
        return null;
    }
}
